<?php

namespace Business;

class Photo extends Base {

	public function addComment($userId, $photoId, $content) {
		$content = $this->stripContent($content);
		$len = mb_strlen($content);
		if (!$content || $len < 4) {
			$this->throwException('评论太短了！');
		}
		if ($len > 1500) {
			$this->throwException('评论太长了！');
		}
		\Data\PhotoComments::instance()->addComment($userId, $photoId, $content);
	}

	public function getCommentsByArticleId($photoId, $pager) {
		$result = \Data\PhotoComments::instance()->getCommentsByPhotoId($photoId, $pager);
		return $result;
	}

	private function stripContent($content) {
		$content = strip_tags($content, '<p><u><span><img><br>');
		$content = trim($content);
		return $content;
	}
}